package ServletOverWhere;

/**
 * @author 李某
 * * @date 2021/11/20
 * *物有本末，事有终始。知其先后者，则近道矣！
 * *荷花开满池塘的前一天还是半塘荷花半塘云。
 */




import java.io.IOException;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

    /**
     * Servlet implementation class PageRedirect
     */
    @WebServlet("/PageRedirect")
    public class PageRedirect extends HttpServlet{

        public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
                throws ServletException, IOException
        {
            // 设置响应内容类型
            response.setContentType("text/html;charset=UTF-8");

            // 要重定向的新位置
            String site = new String("http://www.runoob.com");

            response.setStatus(response.SC_MOVED_TEMPORARILY);
            response.setHeader("Location", site);
        }
    }


/**
 * ....
 *  <servlet>
 *      <servlet-name>PageRedirect</servlet-name>
 *      <servlet-class>PageRedirect</servlet-class>
 *  </servlet>
 *
 *  <servlet-mapping>
 *      <servlet-name>PageRedirect</servlet-name>
 *      <url-pattern>/TomcatTest/PageRedirect</url-pattern>
 *  </servlet-mapping>
 * ....
 */





